<!-- ------------------------------------------------------------------------- -->
<!-- ------------------------------------------------------------------------- -->
<!-- ---------------------- 流调管理--确诊病例管理 ---------------------------- -->
<!-- ------------------------------------------------------------------------- -->
<!-- ------------------------------编辑的tag---------------------------------- -->
<!-- -------------------------编辑的tag--危险因素与暴露史----------------------------- -->



<template>
  <div class="box">
    <el-form
    ref="ruleFormRef"
    :model="ruleForm"
    :rules="rules"
    label-width="120px"
    class="demo-ruleForm"
    :size="formSize"
    status-icon
  >
    <el-form-item label="是否为孕妇:" prop="count">
      <el-radio-group v-model="ruleForm.resource">
        <el-radio label="是" />
        <el-radio label="否" />
      </el-radio-group>
    </el-form-item>
    <el-form-item label="孕周:" prop="count">
      <el-input v-model="ruleForm.name" style="width: 300px" />
    </el-form-item>
    <el-form-item label="是否吸烟:" prop="count">
      <el-radio-group v-model="ruleForm.resource">
        <el-radio label="是" />
        <el-radio label="否" />
      </el-radio-group>
    </el-form-item>
    <el-form-item label="吸烟频次:" prop="count">
      <el-input v-model="ruleForm.name" style="width: 300px" />
    </el-form-item>

    <el-form-item style="padding-top: 200px">
      <el-button @click="resetForm(ruleFormRef)">取消</el-button>
      <el-button type="primary" @click="submitForm(ruleFormRef)">
        确定
      </el-button>
    </el-form-item>
  </el-form>
  </div>
 
</template>

<script lang="ts">
import { defineComponent, reactive, ref } from "vue";
import type { FormInstance, FormRules } from "element-plus";
export default defineComponent({
  name: "RiskFactors",
  setup() {
    const formSize = ref("large");
    const ruleFormRef = ref<FormInstance>();
    const ruleForm = reactive({
      name: "Hello",
      region: "",
      count: "",
      date1: "",
      date2: "",
      delivery: false,
      type: [],
      resource: "",
      desc: "",
    });

    const rules = reactive<FormRules>({
      name: [
        {
          required: true,
          message: "Please input Activity name",
          trigger: "blur",
        },
        { min: 3, max: 5, message: "Length should be 3 to 5", trigger: "blur" },
      ],
      region: [
        {
          required: true,
          message: "Please select Activity zone",
          trigger: "change",
        },
      ],
      count: [
        {
          required: false,
          message: "Please select Activity count",
          trigger: "change",
        },
      ],
      date1: [
        {
          type: "date",
          required: true,
          message: "Please pick a date",
          trigger: "change",
        },
      ],
      date2: [
        {
          type: "date",
          required: true,
          message: "Please pick a time",
          trigger: "change",
        },
      ],
      type: [
        {
          type: "array",
          required: true,
          message: "Please select at least one activity type",
          trigger: "change",
        },
      ],
      resource: [
        {
          required: true,
          message: "Please select activity resource",
          trigger: "change",
        },
      ],
      desc: [
        {
          required: true,
          message: "Please input activity form",
          trigger: "blur",
        },
      ],
    });

    const submitForm = async (formEl: FormInstance | undefined) => {
      if (!formEl) return;
      await formEl.validate((valid, fields) => {
        if (valid) {
          console.log("submit!");
        } else {
          console.log("error submit!", fields);
        }
      });
    };

    const resetForm = (formEl: FormInstance | undefined) => {
      if (!formEl) return;
      formEl.resetFields();
    };

    const options = Array.from({ length: 10000 }).map((_, idx) => ({
      value: `${idx + 1}`,
      label: `${idx + 1}`,
    }));

    return {
      formSize,
      ruleFormRef,
      ruleForm,
      rules,
      submitForm,
      resetForm,
      options,
    };
  },
});
</script>

<style scoped lang="less">
.box{
  width: 100%;
  background-color: #fff;
}
.el-form {
  width: 90%;
  background-color: #fff;
  padding-top: 100px;
  height: 70vh;
}
.el-form-item {
  height: 50px;
}
</style>
